import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        debugShowCheckedModeBanner: false,
        home: Scaffold(
          appBar: AppBar(
            title: Text('demo'),
          ),
          body: HomeContent(),
        ),
        theme: ThemeData(primarySwatch: Colors.yellow));
  }
}

class HomeContent extends StatelessWidget {
  List<Widget> _getData() {
    List<Widget> list = [];
    for (var i = 0; i < 30; i++) {
      list.add(Container(
        color: Colors.blue[50],
        height: 400, //设置高度无反应
        child: Text('文本$i',
            style: TextStyle(
              fontSize: 30,
            )),
      ));
    }
    return list;
  }

  @override
  Widget build(BuildContext context) {
    return GridView.count(
      crossAxisCount: 2, //一行的数量
      mainAxisSpacing: 20,
      crossAxisSpacing: 20,
      childAspectRatio: 0.7,
      padding: EdgeInsets.all(10),
      children: this._getData(),
    );
  }
}
